package com.mewpipe.adminservlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.mewpipe.dao.DaoFactory;
import com.mewpipe.dao.UserDao;

@SuppressWarnings("serial")
@WebServlet ("/AdminContent/DeleteUser")





	
public class DeleteUserServlet extends HttpServlet{
	private UserDao userDao;
	@Override
	public void init() throws ServletException {
		userDao = DaoFactory.getInstance().getUserDao();
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		String str_id =  req.getParameter("id");
		long id = Long.parseLong(str_id);
		 userDao.deleteUserById(id);
		 resp.sendRedirect(req.getServletContext().getContextPath()+ "/AdminContent/GestionUser");
		

	}
	
}

